package org.ecshop.controllers;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.ecshop.models.GoodsGallery;

import will.icecoffe.core.DataAccessException;
import will.icecoffe.core.SimpleDataAccessService;

import com.opensymphony.xwork2.ModelDriven;



public class GoodsGalleryController implements ModelDriven<Object>{

	private final String domainName = "http://www.xingouwu360.com/";
	
	private int id;
	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	//private GoodsGallery model = new GoodsGallery();
	private List<GoodsGallery> list = new ArrayList<GoodsGallery>();
	
	@Resource(name="DAS")
	private SimpleDataAccessService<GoodsGallery> das;
	
	public String show() throws DataAccessException {
		System.out.println(id);
		list = das.find("hql", "findPhotosByGoodsId", id);
		for(GoodsGallery gg : list) {
			gg.setThumbUrl(this.domainName + gg.getThumbUrl());
			gg.setImgUrl(this.domainName + gg.getImgUrl());
			gg.setImgOriginal(this.domainName + gg.getImgOriginal());
		}
		return null;
	}

	@Override
	public Object getModel() {
		return list;
	}
	
}
